package com.edu.zut.hb.software.server.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.edu.zut.hb.software.server.pojo.UpdateVo.TeacherUpdateVo;
import com.edu.zut.hb.software.server.pojo.registerVo.TeacherRegisterVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;

/**
 * <p>
 *
 * </p>
 *
 * @author zhoubin
 * @since 2021-08-15
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@TableName("ks_teacher")
@ApiModel(value = "Teacher对象", description = "")
public class Teacher implements Serializable, UserDetails {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "教师姓名")
    @TableField("name")
    private String name;

    @ApiModelProperty(value = "教师工号")
    @TableId(value = "id", type = IdType.AUTO)
    private String id;

    @ApiModelProperty(value = "教师登录密码")
    @TableField("password")
    private String password;


    @ApiModelProperty(value = "教师所在教研室")
    @TableField("room")
    private Integer room;

    @ApiModelProperty(value = "教师所带班级")
    @TableField("clazz")
    private Integer clazz;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return id;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    public Teacher(TeacherRegisterVo param) {
        this.name = param.getName();
        this.password = param.getPassword();
        this.room = param.getRoom();
        this.clazz = param.getClazz();
    }

    public Teacher(TeacherUpdateVo updateVo) {
        this.id = updateVo.getId();
        this.name = updateVo.getName();
        this.password = updateVo.getPassword();
        this.room = updateVo.getRoom();
        this.clazz = updateVo.getClazz();

    }
}
